//
//  ClassifyCell.swift
//  Eternity
//
//  Created by cll12_12 on 2016/12/5.
//  Copyright © 2016年 ZhengWei. All rights reserved.
//

import UIKit

class ClassifyCell: UICollectionViewCell {
    
    // MARK: - life cycle
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initBaseLayout()
        layoutPageSubview()
        self.backgroundColor = UIColor.white
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - private method
    func initBaseLayout() {
        self.addSubview(iconImageView)
        self.addSubview(titleLabel)
    }
    
    func layoutPageSubview() {
        iconImageView.snp.makeConstraints { (make) in
            make.top.equalTo(self).offset(0)
            make.centerX.equalTo(self)
            make.width.height.equalTo(64)
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.bottom.equalTo(self).offset(-20)
            make.centerX.equalTo(self)
            make.width.equalTo(64)
            make.height.equalTo(14)
        }
    }
    
    func configUI() {
        iconImageView.sd_setImage(with: URL(string: "http://img15.3lian.com/2015/h1/57/d/61.jpg"), placeholderImage: UIImage(named: "def_64x64"))
        _titleLabel.text = "限量套装"
    }
    
    // MARK: - setters and getters
    var _iconImageView: UIImageView!
    var iconImageView: UIImageView {
        if _iconImageView == nil {
            _iconImageView = UIImageView()
            
        }
        return _iconImageView
    }
    
    var _titleLabel: UILabel!
    var titleLabel: UILabel {
        if _titleLabel == nil {
            _titleLabel = UILabel()
            _titleLabel.font = UIFont(name: "PingFang-SC-Light", size: 12)
            _titleLabel.textColor = UIColor(hexString: "#252525")
            _titleLabel.textAlignment = .center
        }
        return _titleLabel
    }
}
